import { Controller, Post, Get, Query } from '@nestjs/common';
import { GoodsService } from "../../services/goods/goods.service";
import { ApiTags, ApiResponse, ApiQuery } from '@nestjs/swagger';
import { Crud } from '@nestjsx/crud';
import { Goods } from "../../entities/goods.entity";

@Crud({
  model:{
    type: Goods
  },
  query: {
    join:{
      brand:{
        exclude:["sort_order","is_show","is_new","app_list_pic_url"]
      },
      category:{
        exclude:["keywords","parent_id","sort_order","show_index","is_show","level","type"]
      },
      goodsAttribute:{
        exclude:["goods_id","attribute_id","id"]
      },
      goodsSpecification:{
        exclude:["goods_id","specification_id"]
      },
      product:{
        exclude:['goods_id']
      },
      'goodsAttribute.attribute':{
        exclude:["attribute_category_id","input_type","value","sort_order"]
      },
      'goodsSpecification.specification':{
        exclude:["sort_order"]
      },
      couponGoods:{
        exclude:[]
      },
      'couponGoods.coupon':{
        exclude:[]
      }
    },
    exclude:["category_id","brand_id","keywords","is_on_sale","is_delete","attribute_category","is_new","app_exclusive_price","is_app_exclusive","is_limited","is_hot","create_user_id","update_user_id","create_user_dept_id","promotion_tag","add_time","update_time","counter_price","extra_price","unit_price"],
    filter: {
      is_delete:{
        $eq:0
      },
      is_on_sale:{
        $eq:1
      }
    },
    sort:[
      {
        field:'sort_order',
        order:'DESC'
      }
    ],
  }
})
@ApiTags('goods')
@Controller('api/goods')
export class GoodsController {
  constructor(
    public readonly service: GoodsService
  ){}
}
